import { createRouter, createWebHistory } from 'vue-router'
import NProgress from "@/utils/progress";
import routes from "./routes";
import { useTitle } from '@vueuse/core'
import { pageDefaultTitle } from '@/settings';

const router = createRouter({
  history: createWebHistory(import.meta.env.VITE_BASE_URL),
  routes
})


router.beforeEach((to, from, next) => {
  NProgress.start();
  useTitle(to.meta.title || pageDefaultTitle)
  next();
})

router.afterEach(() => {
  NProgress.done();
})

export default router